﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Weazel.Toad.Application.Controls
{
	[ToolboxItem(false)]
	public partial class CustomBorderPanel : UserControl
	{
		[Category("Appearance")]
		private Border3DSide borderSide = Border3DSide.Bottom;
		public Border3DSide BorderSide
		{
			get { return borderSide; }
			set { borderSide = value; }
		}

		[Category("Appearance")]
		private System.Windows.Forms.Border3DStyle borderStyle = Border3DStyle.RaisedInner;
		public new System.Windows.Forms.Border3DStyle BorderStyle
		{
			get { return borderStyle; }
			set { borderStyle = value; }
		}

		/// <summary>
		/// Creates a new <see cref="CustomBorderPanel"/> instance.
		/// </summary>
		public CustomBorderPanel()
		{
			InitializeComponent();
		}

		protected override void OnPaint(PaintEventArgs pe)
		{
			// Calling the base class OnPaint
			base.OnPaint(pe);

			switch (BorderSide)
			{
				case Border3DSide.Top:
					ControlPaint.DrawBorder3D(pe.Graphics, 0, 1, this.Width, 0, borderStyle);
					break;
				case Border3DSide.Bottom:
					ControlPaint.DrawBorder3D(pe.Graphics, 0, this.Height, this.Width, 0, borderStyle);
					break;
				default:
					throw new NotSupportedException(string.Format("Border3DSide: {0} is not supported", borderSide));
			}
		}
	}
}
